package com.cn.udpDemo.message;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.nio.ByteBuffer;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message {
    private byte type; //类型
    private int uri; //
    private int size;
    // 消息体
    private byte[] data;

    public static void main(String[] args) {
        ByteBuffer buffer =ByteBuffer.allocate(13);
        buffer.putInt(12345);
        buffer.flip();
        System.out.println(buffer.getInt());
    }
    public static Message build(byte type){
        byte [] bytes = {};
        Message message=new Message(type,12345,bytes.length,bytes);
        return message;
    }
}
